home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
BROWSER.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-17
|
10KB
|
335 lines
// BROWSER.HPP //
// Contents ----------------------------------------------------------------
//
// This header contains the following items:
//
// 1. Class PXListBox. Redefines listboxes for browsing PDOX tables.
//
// 2. Stucture LB_PARM. Stores the parameters for all the list boxes.
//
// 3. Class DBDISPLAY. Displays the database in page format with 20
// records per page.
//
// 4. Class PXScroller. Redifines the scroller for scrolling PDOX
// tables. The vertical scroll is all that is redefined.
//
// 5. Class Browser. Creates a browser window that is MDI complient.
//
// 6. Class BrowserFrame. Creates a MDI frame for creating browser
// windows.
//
// Description
//
// This header contains all the interfaces classes and structures to
// construct MDI complient browser windows for Windows application
// interface of PDOX tables.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef BROWSER_HPP
#define BROWSER_HPP
// End ---------------------------------------------------------------------
// Interface Dependendies --------------------------------------------------
#ifndef __STRING_H
#include <string.h>
#endif
#ifndef __STDIO_H
#include <stdio.h>
#endif
#ifndef __OWL_H
#include <owl.h>
#endif
#ifndef __FILEDIAL_H
#include <filedial.h>
#endif
#ifndef __MDI_H
#include <mdi.h>
#endif
#ifndef __LISTBOX_H
#include <listbox.h>
#endif
#ifndef __STATIC_H
#include <static.h>
#endif
#ifndef PXSTRUCT_CPP
#include "pxstruct.cpp"
#endif
// End ---------------------------------------------------------------------
#define PAGE_SIZE 20 /* The number of records in
a page */
#define WM_CHKCHILD 0x400 /* To send a message to the
BrowserFrame when a
child is destroyed */
#define WM_SETWTCUR 0x410 /* Cursor wait message */
#define WM_SETNMCUR 0x420 /* Cursor normal message */
// structure LB_PARM //
class PXListBox;
class Browser;
typedef struct LB_PARM{
PXField *my_field; /* Points to the field
cooresponding to this
list box */
int x; /* X coordinates of origin
point of list box */
int w; /* Width of list box */
PXListBox *my_box; /* Points to the list box
object */
TStatic *my_header; /* Points to field header
static text block object
*/
}LB_PARM;
// Description -------------------------------------------------------------
//
// This structure is used to define the parameters necessary to
// construct and use a list box for each field in the database.
//
// End ---------------------------------------------------------------------
// class DBDISPLAY //
#define CHAR_WIDTH 8 /* This is the size of a
character */
class DBDISPLAY:public PXDIS
{
protected:
LB_PARM **my_parm; /* Define an array of
pointers for the fields
parameter set */
int sum; /* sum is the total number of
characters it takes to
display all the fields.
This will be used to set
the scroll bar range. */
RECORDNUMBER top_rec; /* Top record number */
int item; /* List box item number */
int UpdateFlag; /* Update display if set */
PTWindowsObject AP; /* Copy of parent object */
public:
DBDISPLAY();
int RetSum() /* Returns the total number
of characters in all
fields */
{
return sum;
}
virtual ~DBDISPLAY();
int SetUp(Browser *AParent); /* Set up database display */
void SelRecord(int item); /* Selects the record at a
certain list box item
number */
void FillBoxes(RECORDNUMBER rec); /* Fills list boxes with
data */
void ScrollUp(); /* Scrolls the page up by one
record */
void ScrollDwn(); /* Scrolls the page down by
one record */
void IncRec(); /* Increments by one record
*/
void DecRec(); /* Decrements by one record
*/
RECORDNUMBER RetCurRec() /* Return current record */
{
return top_rec + item;
}
int RetFlag() /* Returns status of update
flag to test if display
should be updated or not
*/
{
return UpdateFlag;
}
};
// Description -------------------------------------------------------------
//
// This class contains all the members necessary to initialize, browse
// and edit the database.
//
// End ---------------------------------------------------------------------
// class Browser //
class Browser:public TWindow
{
private:
int flag; /* Existance flag for window
bailout */
public:
DBDISPLAY *my_display; /* My database display
object */
char *name; /* Name of database file */
Browser(PTWindowsObject AParent,int ChildNum);
virtual ~Browser();
virtual void SetupWindow();
int RetFlag() /* Return existance flag */
{
return flag;
}
};
// Description -------------------------------------------------------------
//
// This class will be used for each browser window you wish to use.
//
// End ---------------------------------------------------------------------
// class PXListBox //
class PXListBox:public TListBox
{
private:
DBDISPLAY *my_display; /* Display object pointer */
public:
PXListBox(Browser *AParent,
int AnId,int X,int Y,int W,int H,
PTModule AModule = NULL);
virtual void LBNSelChange(RTMessage Msg) =
[NF_FIRST + LBN_SELCHANGE];
// Redefine WMPaint so that list boxes are not drawn when the
// the Update flag is reset. Since the OWL will do screen refresh
// on the list boxes for each new entrie in the box, it is better
// to do a paint after the list has completely been updated.
virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT];
};
// Description -------------------------------------------------------------
//
// The PXListBox class is a modification of the TListBox class. A
// pointer to the DBDISPLAY object is passed. This object is used
// to call the SelRecord function. If a selection event occurs in
// any of the list boxes, the list box calls the SelRecord function
// that selects all the other fields so that the record bar changes
// to coorespond to that item. The focus remains set at the item
// you have selected.
//
// End ---------------------------------------------------------------------
// class PXScroller //
class PXScroller:public TScroller
{
private:
DBDISPLAY *my_display; /* Copy of database display
routine */
public:
PXScroller(Browser *TheWindow,
int TheXUnit,int TheYUnit,long TheXRange,long TheYRange):
TScroller((PTWindow)TheWindow,TheXUnit,TheYUnit,
TheXRange,TheYRange)
{
my_display = TheWindow->my_display;
}
virtual void VScroll(WORD ScrollEvent, /* Redefine vert. scroll */
int ThumbPos);
};
// Description -------------------------------------------------------------
//
// This class customizes the scroller for operation with the database.
// The horizontal scroller is OK but the vertical scroller needs to
// be modified so that only the data scrolls and not the whole window.
//
// End ---------------------------------------------------------------------
// function CountChild //
void CountChild(void *,void *CountPtr)
{
++*(int *)CountPtr;
}
// Summary -----------------------------------------------------------------
//
// This function keeps track of the number of child windows you have
// opened.
//
// Parameters
//
// I don't understand how this function works.
//
// Return Value
//
// None.
//
// Functional Description
//
// For each window increment the counter.
//
// End ---------------------------------------------------------------------
// class BrowserFrame //
class BrowserFrame:public TMDIFrame
{
private:
PXI *engine; /* Pointer to engine
initialization object */
int error; /* error flag */
WNDCLASS *MyClass; /* Windows class */
public:
/* Browser frame constructor
*/
BrowserFrame(LPSTR ATitle);
/* Create a child window */
virtual PTWindowsObject CreateChild();
~BrowserFrame(); /* Close down all your
children */
/* Set up frame to so that
you can have child
windows */
void SetupWindow();
/* If a file open command is
recieved, open a new
browser window */
virtual void CreateBrowser(RTMessage Msg) =
[CM_FIRST + CM_FILEOPEN];
/* Count the number of child
windows. */
int GetChildCount();
void MenuItemDisable(int item); /* Disable a menu item */
void MenuItemEnable(int item); /* Enable a menu item */
/* Check your children. This
message is sent by the
browser fram that is in
the process of destroying
itself. */
virtual void CheckChildren(RTMessage Msg) =
[WM_CHKCHILD];
virtual void GetWindowClass(WNDCLASS& AWndClass);
/* Set the mouse cursor to
hour glass type */
virtual void CursorWait(RTMessage Msg) =
[WM_SETWTCUR];
/* Set the mouse cursor to
normal type */
virtual void CursorNormal(RTMessage Msg) =
[WM_SETNMCUR];
};
// Description -------------------------------------------------------------
//
// This class allows construction of the MDI frame which will hold all
// the child windows.
//
// End ---------------------------------------------------------------------
#endif